
package priv.conceit.sc.hoxton.common.web;

import lombok.Getter;
import lombok.Setter;

/**
 * restful 统一返回结果集
 * @author: conceit
 * @Date: 2020/9/15
 */
@Getter
@Setter
public class WebResponse<T> {

	/**
	 * 状态码
	 */
	private Integer stateCode = 200;

	/**
	 * 自定义消息
	 */
	private String message = "success";

	/**
	 * 结果集
	 */
	private T result;

	public WebResponse() {
	}


	public static <T> WebResponse build(Integer stateCode, String message, T t) {
		WebResponse response = new WebResponse();
		response.setStateCode(stateCode);
		response.setMessage(message);
		response.setResult(t);
		return response;
	}

	public static <T> WebResponse build(Integer stateCode, String message) {
		WebResponse response = new WebResponse();
		response.setStateCode(stateCode);
		response.setMessage(message);
		return response;
	}

	public static <T> WebResponse build(T t) {
		WebResponse response = new WebResponse();
		response.setResult(t);
		return response;
	}
	public static WebResponse build() {
		return new WebResponse();
	}

}
